package com.modai.springcloud.entities;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.cloud.stream.messaging.Sink;
import org.springframework.messaging.Message;

/**
 * @author ：modai
 * @date ：Created in 2020-12-13 20:49
 * @description：
 */
@EnableBinding(value = Sink.class)
@Slf4j
public class ConsumerController {
    @Value("${server.port}")
    private String serverPort;

    @StreamListener(Sink.INPUT)
    public void getMessage(Message<String> message){
        String payload = message.getPayload();
        log.info("---->本节点： "+serverPort+"\t 获取了数据："+payload);
    }
}
